describe("api_transfer in SG", function() {
    var callback;
    var fakeObject;

    beforeEach(function() {
        App.initSession();
        callback = jasmine.createSpy();
        fakeObject = {
            fetch: function(transfer, callback) {}
        };
        confirmFakeObject = {
        	confirm: function(transfer, callback) {}
        };
        transferFakeObject = {
        	fundTransferDataVO: function() {}
        };
    });
    
    describe("App.api_transfer -- fetchToListForTransfer", function() {
    	var api_transfer;

        it("transfer is App.BillPayment", function() {
        	var transfer = App.BillPayment.create();
            spyOn(App.BillPayeeListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');
        	
        	App.api_transfer.fetchToListForTransfer(transfer, callback);
        	
        	expect(fakeObject.fetch).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.OneTimeBillPayment", function() {
        	var transfer = App.OneTimeBillPayment.create();
            spyOn(App.OneTimeBillPayeeListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');
        	
        	App.api_transfer.fetchToListForTransfer(transfer, callback);
        	
        	expect(fakeObject.fetch).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.TopUpPayment", function() {
        	var transfer = App.TopUpPayment.create();
            spyOn(App.TopUpBillPayeeListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');
        	
        	App.api_transfer.fetchToListForTransfer(transfer, callback);
        	
        	expect(fakeObject.fetch).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.OneTimeTopUpPayment", function() {
        	var transfer = App.OneTimeTopUpPayment.create();
            spyOn(App.OneTimeTopUpBillPayeeListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');
        	
        	App.api_transfer.fetchToListForTransfer(transfer, callback);
        	
        	expect(fakeObject.fetch).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.OtherBankCreditCardPayment", function() {
        	var transfer = App.OtherBankCreditCardPayment.create();
            spyOn(App.OtherBankCreditCardPayeeListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');
        	
        	App.api_transfer.fetchToListForTransfer(transfer, callback);
        	
        	expect(fakeObject.fetch).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.OwnAccountTransfer", function() {
        	var transfer = App.OwnAccountTransfer.create();
            spyOn(App.OwnAccountToListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');
        	
        	App.api_transfer.fetchToListForTransfer(transfer, callback);
        	
        	expect(fakeObject.fetch).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.ThirdPartyTransfer", function() {
        	var transfer = App.ThirdPartyTransfer.create();
            spyOn(App.ThirdPartyPayeeListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');
        	
        	App.api_transfer.fetchToListForTransfer(transfer, callback);
        	
        	expect(fakeObject.fetch).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.CreditCardPayment", function() {
        	var transfer = App.CreditCardPayment.create();
            spyOn(App.CreditCardToListFetcher, 'create').andReturn(fakeObject);
            spyOn(fakeObject, 'fetch');
        	
        	App.api_transfer.fetchToListForTransfer(transfer, callback);
        	
        	expect(fakeObject.fetch).toHaveBeenCalledWith(transfer, callback);
        });
    });

    describe("App.api_transfer -- confirmTransfer", function() {
    	var api_transfer;

        it("transfer is App.BillPayment", function() {
        	var transfer = App.BillPayment.create();
            spyOn(App.ConfirmBillPaymentTransfer, 'create').andReturn(confirmFakeObject);
            spyOn(confirmFakeObject, 'confirm');
        	
            App.api_transfer.confirmTransfer(transfer, callback);
        	
        	expect(confirmFakeObject.confirm).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.OneTimeBillPayment", function() {
        	var transfer = App.OneTimeBillPayment.create();
        	spyOn(App.ConfirmBillPaymentTransfer, 'create').andReturn(confirmFakeObject);
            spyOn(confirmFakeObject, 'confirm');
        	
            App.api_transfer.confirmTransfer(transfer, callback);
        	
        	expect(confirmFakeObject.confirm).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.TopUpPayment", function() {
        	var transfer = App.TopUpPayment.create();
        	spyOn(App.ConfirmBillPaymentTransfer, 'create').andReturn(confirmFakeObject);
            spyOn(confirmFakeObject, 'confirm');
        	
            App.api_transfer.confirmTransfer(transfer, callback);
        	
        	expect(confirmFakeObject.confirm).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.OneTimeTopUpPayment", function() {
        	var transfer = App.OneTimeTopUpPayment.create();
        	spyOn(App.ConfirmBillPaymentTransfer, 'create').andReturn(confirmFakeObject);
            spyOn(confirmFakeObject, 'confirm');
        	
            App.api_transfer.confirmTransfer(transfer, callback);
        	
        	expect(confirmFakeObject.confirm).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.OwnAccountTransfer", function() {
        	var transfer = App.OwnAccountTransfer.create();
            spyOn(App.ConfirmOwnAccountTransfer, 'create').andReturn(confirmFakeObject);
            spyOn(confirmFakeObject, 'confirm');
        	
        	App.api_transfer.confirmTransfer(transfer, callback);
        	
        	expect(confirmFakeObject.confirm).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.ThirdPartyTransfer", function() {
        	var transfer = App.ThirdPartyTransfer.create();
            spyOn(App.ConfirmThirdPartyTransfer, 'create').andReturn(confirmFakeObject);
            spyOn(confirmFakeObject, 'confirm');
        	
        	App.api_transfer.confirmTransfer(transfer, callback);
        	
        	expect(confirmFakeObject.confirm).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.CreditCardPayment", function() {
        	var transfer = App.CreditCardPayment.create();
            spyOn(App.ConfirmCreditCardPayment, 'create').andReturn(confirmFakeObject);
            spyOn(confirmFakeObject, 'confirm');
        	
        	App.api_transfer.confirmTransfer(transfer, callback);
        	
        	expect(confirmFakeObject.confirm).toHaveBeenCalledWith(transfer, callback);
        });
        
        it("transfer is App.OtherBankCreditCardPayment", function() {
        	var transfer = App.OtherBankCreditCardPayment.create();
            spyOn(App.ConfirmOtherBankCreditCardTransfer, 'create').andReturn(confirmFakeObject);
            spyOn(confirmFakeObject, 'confirm');
        	
        	App.api_transfer.confirmTransfer(transfer, callback);
        	
        	expect(confirmFakeObject.confirm).toHaveBeenCalledWith(transfer, callback);
        });
    });
    
    describe("App.api_transfer -- CreditCardToListFetcher", function() {
    	var creditCardToListFetcher;

        beforeEach(function() {
        	creditCardToListFetcher = App.CreditCardToListFetcher.create();
        	creditCardToListFetcher.callbackTransfer = callback;
        });

        it("productList success and payeeList is null", function() {
        	var transfer = {};
            var response = {
        		"productListResponse": {
        			"productList": [],
        			"responseHeader": {
        				"status": 1,
        				"currentTimestamp": "2013-07-01T15:24:12.755+0800",
        				"nonce": "26e8dc1aa7049b939843d984d7dfbe05"
        			}
        		}
        	};
            
            creditCardToListFetcher.processList(transfer, response);
            
            expect(creditCardToListFetcher.callbackTransfer).toHaveBeenCalled();
        });

        it("productList success and payeeList is not null", function() {
        	var transfer = {};
        	var response = {
            		"productListResponse": {
            			"productList": [{
            				"productCategory": "CASA",
            				"productCode": "CCA",
            				"subProductCode": "2",
            				"accountNumber": "4300920020978878",
            				"accountName": "VISA PLATINUM REWARDS",
            				"accountDescription": "VISA PLATINUM REWARDS",
            				"currencyCode": "SGD",
            				"currentBalance": 0,
            				"availableBalance": 44000,
            				"onlineFlag": false,
            				"productGroup": "CARD",
            				"accountType": "VISA PLATINUM REWARDS",
            				"productDescription": "CREDIT CARD ACCOUNT",
            				"productIndex": "T-0"
            			}],
            			"responseHeader": {
            				"status": 1,
            				"currentTimestamp": "2013-07-01T15:24:12.755+0800",
            				"nonce": "26e8dc1aa7049b939843d984d7dfbe05"
            			}
            		}
            	};
            
            creditCardToListFetcher.processList(transfer, response);
            
            expect(creditCardToListFetcher.callbackTransfer).toHaveBeenCalled();
        });
        
        it("productList error", function() {
        	var transfer = {};
            var response = {
        		anyCardPaymentPayeeListResponse: {
        			responseHeader: {
        				status: 0,
        				nonce: "b3c56d7f63df9fc5d20699039f29c735",
        				currentTimestamp: "2013-04-28T14:07:09.260+0800"
        			}
        		}
        	};
            
            creditCardToListFetcher.processList(transfer, response);
            
            expect(creditCardToListFetcher.callbackTransfer).toHaveBeenCalled();
        });
        
    });
    
    describe("App.ListFetcherBase -- generateAccountFromResponseData", function() {
        var listFetcherBase;

        beforeEach(function() {
            listFetcherBase = App.ListFetcherBase.create();
        });

        it("accountData is null", function() {
            expect(listFetcherBase.generateAccountFromResponseData(null)).toEqual(null);
        });

        it("accountData.productCategory is CASA, accountData.productCode is CCA, should return CardAccount", function() {
            var accountData = {
                productCategory: 'CASA',
                productCode: 'CCA'
            };

            var result = listFetcherBase.generateAccountFromResponseData(accountData);
            expect(result instanceof App.CardAccount).toBeTruthy();
            expect(result.productCategory).toEqual(accountData.productCategory);
            expect(result.productCode).toEqual(accountData.productCode);
        });

        it("accountData.productCategory is CASA, accountData.productCode is not CCA, should return HaveAccount", function() {
            var accountData = {
                productCategory: 'CASA',
                productCode: 'DDA'
            };

            var result = listFetcherBase.generateAccountFromResponseData(accountData);
            expect(result instanceof App.HaveAccount).toBeTruthy();
            expect(result.productCategory).toEqual(accountData.productCategory);
            expect(result.productCode).toEqual(accountData.productCode);
        });

        it("accountData.productCategory is CARD, should return CardAccount", function() {
            var accountData = {
                productCategory: 'CARD'
            };

            var result = listFetcherBase.generateAccountFromResponseData(accountData);
            expect(result instanceof App.CardAccount).toBeTruthy();
            expect(result.productCategory).toEqual(accountData.productCategory);
        });
    });

    describe("App.FromListFetcher -- fetch", function() {
        var fromListFetcher;

        beforeEach(function() {
            fromListFetcher = App.FromListFetcher.create();
        });

        it("transfer is OwnAccountTransfer", function() {
            var transfer = App.OwnAccountTransfer.create();
            spyOn(bsoi, 'filterProductList');

            fromListFetcher.fetch(transfer, callback);

            expect(fromListFetcher.callbackTransfer).toEqual(callback);
            expect(bsoi.filterProductList).toHaveBeenCalled();
        });

        it("transfer is ThirdPartyTransfer", function() {
            var transfer = App.ThirdPartyTransfer.create();
            spyOn(bsoi, 'filterProductList');

            fromListFetcher.fetch(transfer, callback);

            expect(fromListFetcher.callbackTransfer).toEqual(callback);
            expect(bsoi.filterProductList).toHaveBeenCalled();
        });
        
        it("transfer is ThirdPartyTransfer and current transfer is SCBTransfer", function() {
            var transfer = App.ThirdPartyTransfer.create();
            spyOn(bsoi, 'filterProductList');
            spyOn(transfer, 'isSCBTransfer').andReturn(true);

            fromListFetcher.fetch(transfer, callback);

            expect(fromListFetcher.callbackTransfer).toEqual(callback);
            expect(bsoi.filterProductList).toHaveBeenCalled();
        });

        it("transfer is ThirdPartyTransfer and current transfer is SCBTransfer", function() {
            var transfer = App.ThirdPartyTransfer.create();
            spyOn(bsoi, 'filterProductList');
            spyOn(transfer, 'isIBFTTransfer').andReturn(true);

            fromListFetcher.fetch(transfer, callback);

            expect(fromListFetcher.callbackTransfer).toEqual(callback);
            expect(bsoi.filterProductList).toHaveBeenCalled();
        });
        
        it("transfer is BillPayment", function() {
            var transfer = App.BillPayment.create();
            spyOn(bsoi, 'filterProductList');

            fromListFetcher.fetch(transfer, callback);

            expect(fromListFetcher.callbackTransfer).toEqual(callback);
            expect(bsoi.filterProductList).toHaveBeenCalled();
        });

        it("transfer is CreditCardPayment", function() {
            var transfer = App.CreditCardPayment.create();
            spyOn(bsoi, 'filterProductList');

            fromListFetcher.fetch(transfer, callback);

            expect(fromListFetcher.callbackTransfer).toEqual(callback);
            expect(bsoi.filterProductList).toHaveBeenCalled();
        });
        
        it("transfer is OtherBankCreditCardPayment", function() {
            var transfer = App.OtherBankCreditCardPayment.create();
            spyOn(bsoi, 'filterProductList');

            fromListFetcher.fetch(transfer, callback);

            expect(fromListFetcher.callbackTransfer).toEqual(callback);
            expect(bsoi.filterProductList).toHaveBeenCalled();
        });
    });

    describe("App.OwnAccountToListFetcher -- fetch", function() {
        var ownAccountToListFetcher;

        beforeEach(function() {
            ownAccountToListFetcher = App.OwnAccountToListFetcher.create();
        });

        it("OAT list call", function() {
            var transfer = {};
            spyOn(bsoi, 'filterProductList');

            ownAccountToListFetcher.fetch(transfer, callback);

            expect(ownAccountToListFetcher.callbackTransfer).toEqual(callback);
            expect(bsoi.filterProductList).toHaveBeenCalled();
        });

    });

    describe("App.OtherBankCreditCardPayeeListFetcher -- fetch", function() {
        var otherBankCreditCardPayeeListFetcher;

        beforeEach(function() {
        	otherBankCreditCardPayeeListFetcher = App.OtherBankCreditCardPayeeListFetcher.create();
        });

        it("fetch", function() {
            var transfer = {};
            spyOn(bsoi, 'getAnyCardPayeeList');

            otherBankCreditCardPayeeListFetcher.fetch(transfer, callback);

            expect(otherBankCreditCardPayeeListFetcher.callbackTransfer).toEqual(callback);
            expect(bsoi.getAnyCardPayeeList).toHaveBeenCalled();
        });

    });
    
    describe("App.OtherBankCreditCardPayeeListFetcher -- processList", function() {
        var otherBankCreditCardPayeeListFetcher;

        beforeEach(function() {
        	otherBankCreditCardPayeeListFetcher = App.OtherBankCreditCardPayeeListFetcher.create();
        	otherBankCreditCardPayeeListFetcher.callbackTransfer = callback;
        });

        it("getAnyCardPayeeList success and payeeList is null", function() {
        	var transfer = {};
            var response = {
        		anyCardPaymentPayeeListResponse: {
        			payeeList: [],
        			responseHeader: {
        				status: 1,
        				nonce: "b3c56d7f63df9fc5d20699039f29c735",
        				currentTimestamp: "2013-04-28T14:07:09.260+0800"
        			}
        		}
        	};
            
            otherBankCreditCardPayeeListFetcher.processList(transfer, response);
            
            expect(otherBankCreditCardPayeeListFetcher.callbackTransfer).toHaveBeenCalled();
        });

        it("getAnyCardPayeeList success and payeeList is not null", function() {
        	var transfer = {};
            var response = {
        		anyCardPaymentPayeeListResponse: {
        			payeeList: [{
        				payeeIndex: "ACP0",
        				payeeId: 8696179,
        				payeeStatus: "A",
        				payeeType: "5",
        				payeeName: "XXX",
        				drAccount: "5520380015755578",
        				payeeShortName: "POSB everyday"
        			}],
        			responseHeader: {
        				status: 1,
        				nonce: "b3c56d7f63df9fc5d20699039f29c735",
        				currentTimestamp: "2013-04-28T14:07:09.260+0800"
        			}
        		}
        	};
            
            otherBankCreditCardPayeeListFetcher.processList(transfer, response);
            
            expect(otherBankCreditCardPayeeListFetcher.callbackTransfer).toHaveBeenCalled();
        });
        
        it("getAnyCardPayeeList error", function() {
        	var transfer = {};
            var response = {
        		anyCardPaymentPayeeListResponse: {
        			responseHeader: {
        				status: 0,
        				nonce: "b3c56d7f63df9fc5d20699039f29c735",
        				currentTimestamp: "2013-04-28T14:07:09.260+0800"
        			}
        		}
        	};
            
            otherBankCreditCardPayeeListFetcher.processList(transfer, response);
            
            expect(otherBankCreditCardPayeeListFetcher.callbackTransfer).toHaveBeenCalled();
        });
    });
    
    
    describe("App.ConfirmTransferBase -- _OTPHandler", function() {
    	var confirmTransferBase;
    	var currentTransfer;

        beforeEach(function() {
        	confirmTransferBase = App.ConfirmTransferBase.create();
        });

        it("Transfer is BillPayment", function() {
            var response = {
            	billPaymentResponse: {
            		isOTPRequired: false,
            		twoFA:{},
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            currentTransfer = App.BillPayment.create();
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(currentTransfer);
            spyOn(App.getSession(), 'setChallengeOpaque');
            spyOn(App.getSession(), 'setSeedValue');

            confirmTransferBase._OTPHandler(response);

            expect(currentTransfer.get('isOTPRequired')).toBeFalsy();
            expect(App.getSession().setChallengeOpaque).toHaveBeenCalledWith(null);
            expect(App.getSession().setSeedValue).toHaveBeenCalledWith(null);
        });

        it("Transfer is ThirdPartyTransfer", function() {
            var response = {
            	thirdPartyFundTransferResponse: {
            		isOTPRequired: null,
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            currentTransfer = App.ThirdPartyTransfer.create();
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(currentTransfer);
            spyOn(App.getSession(), 'setChallengeOpaque');
            spyOn(App.getSession(), 'setSeedValue');

            confirmTransferBase._OTPHandler(response);

            expect(currentTransfer.get('isOTPRequired')).toBeFalsy();
            expect(App.getSession().setChallengeOpaque).toHaveBeenCalledWith(null);
            expect(App.getSession().setSeedValue).toHaveBeenCalledWith(null);
        });
        
        it("Transfer is OtherBankCreditCardPayment", function() {
            var response = {
            	payAnyCardTransferResponse: {
            		isOTPRequired: true,
            		twoFA:{
            			challenge: '111',
            			seedValue: '2222'
            		},
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            currentTransfer = App.OtherBankCreditCardPayment.create();
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(currentTransfer);
            spyOn(App.getSession(), 'setChallengeOpaque');
            spyOn(App.getSession(), 'setSeedValue');

            confirmTransferBase._OTPHandler(response);

            expect(currentTransfer.get('isOTPRequired')).toBeTruthy();
            expect(App.getSession().setChallengeOpaque).toHaveBeenCalledWith('111');
            expect(App.getSession().setSeedValue).toHaveBeenCalledWith('2222');
        });
        
        it("Transfer is OtherBankCreditCardPayment and throw Exception", function() {
            var response = {
            	payAnyCardTransferResponse: {
            		isOTPRequired: true,
            		twoFA:{
            			challenge: '111',
            			seedValue: '2222'
            		},
                    responseHeader: {
                        status: 0,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800",
                        errorCode: 'ERR_SEC_RAE_OTP_TOKEN_INVALID'
                    }
                }
            };
            currentTransfer = App.OtherBankCreditCardPayment.create();
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(currentTransfer);
            spyOn(App.getSession(), 'setChallengeOpaque');
            spyOn(App.getSession(), 'setSeedValue');

            confirmTransferBase._OTPHandler(response);

            expect(currentTransfer.get('isOTPRequired')).toBeTruthy();
            expect(App.getSession().setChallengeOpaque).toHaveBeenCalledWith('111');
            expect(App.getSession().setSeedValue).toHaveBeenCalledWith('2222');
        });
    });
    
    describe("App.ConfirmOwnAccountTransfer -- processConfirmTransferResponse", function() {
        var confirmOwnAccountTransfer;

        beforeEach(function() {
            confirmOwnAccountTransfer = App.ConfirmOwnAccountTransfer.create();
            confirmOwnAccountTransfer.callbackTransfer = callback;
        });

        it("Confirm success and fundTransfer is null", function() {
            var response = {
                ownFundTransferResponse: {
                    fundTransfer: null,
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };

            confirmOwnAccountTransfer.processConfirmTransferResponse(response);

            expect(confirmOwnAccountTransfer.callbackTransfer).toHaveBeenCalledWith(null);
        });

        it("Confirm success and fundTransfer is not null", function() {
            var response = {
                ownFundTransferResponse: {
                    fundTransfer: {
                        transactionRefNo: '0000-0001',
                        amount: 1,
                        fxRate: '1.01'
                    },
                    transactionResult: {
                        transactionStatus: "2"
                    },
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmOwnAccountTransfer.processConfirmTransferResponse(response);

            expect(App.getSession().getCurrentTransfer().equivalentAmount).toEqual(response.ownFundTransferResponse.fundTransfer.amount);
            expect(App.getSession().getCurrentTransfer().indicativeExchangeRate).toEqual(response.ownFundTransferResponse.fundTransfer.fxRate);
            var transferResult = App.TransferResult.create(response.ownFundTransferResponse.transactionResult);
            transferResult.transactionId = response.ownFundTransferResponse.fundTransfer.transactionRefNo;
            expect(confirmOwnAccountTransfer.callbackTransfer).toHaveBeenCalledWith(transferResult);
        });

        it("Confirm error", function() {
            var response = {
                ownFundTransferResponse: {
                    responseHeader: {
                        status: 0,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };

            confirmOwnAccountTransfer.processConfirmTransferResponse(response);

            expect(confirmOwnAccountTransfer.callbackTransfer).toHaveBeenCalled();
        });

    });

    describe("App.ConfirmThirdPartyTransfer -- processConfirmTransferResponse", function() {
        var confirmThirdPartyTransfer;

        beforeEach(function() {
            confirmThirdPartyTransfer = App.ConfirmThirdPartyTransfer.create();
            confirmThirdPartyTransfer.callbackTransfer = callback;
        });

        it("Confirm success and fundTransfer is null", function() {
            var response = {
                thirdPartyFundTransferResponse: {
                    fundTransfer: null,
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmThirdPartyTransfer.processConfirmTransferResponse(response);

            expect(confirmThirdPartyTransfer.callbackTransfer).toHaveBeenCalledWith(null);
        });

        it("Confirm success and fundTransfer is not null", function() {
            var response = {
                thirdPartyFundTransferResponse: {
                    fundTransfer: {
                        transactionRefNo: '0000-0001'
                    },
                    transactionResult: {
                        transactionStatus: "2"
                    },
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmThirdPartyTransfer.processConfirmTransferResponse(response);

            var transferResult = App.TransferResult.create(response.thirdPartyFundTransferResponse.transactionResult);
            transferResult.transactionId = response.thirdPartyFundTransferResponse.fundTransfer.transactionRefNo;
            expect(confirmThirdPartyTransfer.callbackTransfer).toHaveBeenCalledWith(transferResult);
        });

        it("Confirm error", function() {
            var response = {
                thirdPartyFundTransferResponse: {
                    responseHeader: {
                        status: 0,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmThirdPartyTransfer.processConfirmTransferResponse(response);

            expect(confirmThirdPartyTransfer.callbackTransfer).toHaveBeenCalled();
        });

    });
    
    describe("App.ConfirmBillPaymentTransfer -- processConfirmTransferResponse", function() {
        var confirmBillPaymentTransfer;

        beforeEach(function() {
        	confirmBillPaymentTransfer = App.ConfirmBillPaymentTransfer.create();
        	confirmBillPaymentTransfer.callbackTransfer = callback;
        });

        it("Confirm success and payment is null", function() {
            var response = {
                billPaymentResponse: {
                	payment: null,
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmBillPaymentTransfer.processConfirmTransferResponse(response);

            expect(confirmBillPaymentTransfer.callbackTransfer).toHaveBeenCalledWith(null);
        });

        it("Confirm success and payment is not null", function() {
            var response = {
                billPaymentResponse: {
                	payment: {
                        transactionRefNo: '0000-0001'
                    },
                    transactionResult: {
                        transactionStatus: "2"
                    },
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmBillPaymentTransfer.processConfirmTransferResponse(response);

            var transferResult = App.TransferResult.create(response.billPaymentResponse.transactionResult);
            transferResult.transactionId = response.billPaymentResponse.payment.transactionRefNo;
            expect(confirmBillPaymentTransfer.callbackTransfer).toHaveBeenCalledWith(transferResult);
        });

        it("Confirm error", function() {
            var response = {
                billPaymentResponse: {
                    responseHeader: {
                        status: 0,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmBillPaymentTransfer.processConfirmTransferResponse(response);

            expect(confirmBillPaymentTransfer.callbackTransfer).toHaveBeenCalled();
        });

    });
    
    describe("App.ConfirmCreditCardPayment -- processConfirmTransferResponse", function() {
        var confirmCreditCardPayment;

        beforeEach(function() {
            confirmCreditCardPayment = App.ConfirmCreditCardPayment.create();
            confirmCreditCardPayment.callbackTransfer = callback;
        });

        it("Confirm success and payment is null", function() {
            var response = {
                cardPaymentResponse: {
                    payment: null,
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };

            confirmCreditCardPayment.processConfirmTransferResponse(response);

            expect(confirmCreditCardPayment.callbackTransfer).toHaveBeenCalledWith(null);
        });

        it("Confirm success and fundTransfer is not null", function() {
            var response = {
                cardPaymentResponse: {
                    payment: {
                        transactionRefNo: '0000-0001'
                    },
                    transactionResult: {
                        transactionStatus: "2"
                    },
                    responseHeader: {
                        status: 1,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };

            confirmCreditCardPayment.processConfirmTransferResponse(response);

            var transferResult = App.TransferResult.create(response.cardPaymentResponse.transactionResult);
            transferResult.transactionId = response.cardPaymentResponse.payment.transactionRefNo;
            expect(confirmCreditCardPayment.callbackTransfer).toHaveBeenCalledWith(transferResult);
        });

        it("Confirm error", function() {
            var response = {
                cardPaymentResponse: {
                    responseHeader: {
                        status: 0,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };

            confirmCreditCardPayment.processConfirmTransferResponse(response);

            expect(confirmCreditCardPayment.callbackTransfer).toHaveBeenCalled();
        });

    });

    describe("App.ConfirmOtherBankCreditCardTransfer -- confirm", function() {
        var confirmOtherBankCreditCardTransfer;

        beforeEach(function() {
        	confirmOtherBankCreditCardTransfer = App.ConfirmOtherBankCreditCardTransfer.create();
        });

        it("confirm", function() {
        	var transfer = {};
        	spyOn(bsoi, 'anyCardTransfer');
        	spyOn(App.getSession(), 'getCurrentTransfer').andReturn(transferFakeObject);

        	confirmOtherBankCreditCardTransfer.confirm(transfer, callback);

            expect(bsoi.anyCardTransfer).toHaveBeenCalled();
        });
    });
    
    describe("App.ConfirmOtherBankCreditCardTransfer -- processConfirmTransferResponse", function() {
        var confirmOtherBankCreditCardTransfer;

        beforeEach(function() {
        	confirmOtherBankCreditCardTransfer = App.ConfirmOtherBankCreditCardTransfer.create();
        	confirmOtherBankCreditCardTransfer.callbackTransfer = callback;
        });

        it("Confirm success and fundTransfer is null", function() {
            var response = {
        		payAnyCardTransferResponse: {
        			fundTransfer: null,
        			transactionStatus: {
        				transactionStatus: "2"
        			},
        			responseHeader: {
        				status: 1,
        				nonce: "07a7f557fb2338f94647455d2c7e7190",
        				currentTimestamp: "2013-03-27T12:43:10.069+0800"
        			}
        		}
        	};
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmOtherBankCreditCardTransfer.processConfirmTransferResponse(response);

            expect(confirmOtherBankCreditCardTransfer.callbackTransfer).toHaveBeenCalledWith(null);
        });

        it("Confirm success and fundTransfer is not null", function() {
            var response = {
        		payAnyCardTransferResponse: {
        			fundTransfer: {
        				transactionRefNo: "1303-271243780800"
        			},
        			transactionStatus: {
        				transactionStatus: "2"
        			},
        			responseHeader: {
        				status: 1,
        				nonce: "07a7f557fb2338f94647455d2c7e7190",
        				currentTimestamp: "2013-03-27T12:43:10.069+0800"
        			}
        		}
        	};
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmOtherBankCreditCardTransfer.processConfirmTransferResponse(response);

            var transferResult = App.TransferResult.create(response.payAnyCardTransferResponse.transactionResult);
            transferResult.transactionId = response.payAnyCardTransferResponse.fundTransfer.transactionRefNo;
            expect(confirmOtherBankCreditCardTransfer.callbackTransfer).toHaveBeenCalledWith(transferResult);
        });

        it("Confirm error", function() {
            var response = {
            	payAnyCardTransferResponse: {
                    responseHeader: {
                        status: 0,
                        nonce: "07a7f557fb2338f94647455d2c7e7190",
                        currentTimestamp: "2013-03-27T12:43:10.069+0800"
                    }
                }
            };
            spyOn(App.getSession(), 'getCurrentTransfer').andReturn(App.BaseTransfer.create());

            confirmOtherBankCreditCardTransfer.processConfirmTransferResponse(response);

            expect(confirmOtherBankCreditCardTransfer.callbackTransfer).toHaveBeenCalled();
        });

    });
});